﻿using System.Linq;
using System.Web.Mvc;
using CodeSaude.Application.Interfaces;

namespace CodeSaude.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IMenuApplicationService _menuApplicationService;

        public HomeController(IMenuApplicationService menuApplicationService)
        {
            _menuApplicationService = menuApplicationService;
        }


        public ActionResult Index(int id)
        {
            MontarMenuInterno(id);
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        [HttpPost]
        public PartialViewResult MontarMenuInterno(int idMenuPai)
        {
            var lstMenu = _menuApplicationService.GetAll().Where(x => x.ModuloId.Equals(idMenuPai));
            return PartialView("~/Views/Shared/_MenuInterno.cshtml", lstMenu);
        }
    }
}